package kuangsheng;

import java.io.IOException;
import java.net.*;

//不需要连接服务器
public class UDPClientDemo01 {
    public static void main(String[] args) throws IOException {
        //1.建立一个Socker
        DatagramSocket socket = new DatagramSocket();
        //2.建个包
        String msg = "你好呀!服务器!";
        //发送给谁
        InetAddress localhost = InetAddress.getByName("localhost");
        int port = 9099;
        //数据、数据起始、结束、发送给谁
        DatagramPacket datagramPacket = new DatagramPacket(msg.getBytes(), 0, msg.getBytes().length, localhost, port);
        //发送包
        socket.send(datagramPacket);
        //关闭流
        socket.close();
    }
}
